********************************************************************************
*************************** Do File (1): Figures *******************************
********************************************************************************

clear
set more off

use "$data/EPH_1015_format.dta", clear

destring occupation occupation_unemp occup_all, replace

*** Keep only observations that have all the controls used

keep if (occupation !=. & underemp != . & cont_pens !=. & domwk_all !=. & linc_mjob_base08 !=. & lwagehr_mjob_base08 !=. & linc_total_base08 != . & lhours_mjob !=. & age !=. & hhsize !=. & tenure !=. & msa !=. & educyr !=. ///
& attsch_ever !=. & native !=. & lit !=. & gender !=.) | (occupation_unemp != . & age !=. & hhsize !=. & msa !=. & educyr !=. & attsch_ever !=. & native !=. & lit !=. & gender !=.)

keep if gender == 0

********************************************************************************
********************************************************************************

*** Locals for controls

local occup occupation
local base_controls "msa year"
local controls "age age2 hhsize lit native attsch_ever educyr educyr2 i.marstat i.dec_pcfaminc"

local treatFE "y2010_dwall y2011_dwall y2013_dwall y2014_dwall y2015_dwall"

********************************************************************************
********************************************************************************
********************************************************************************

* Run regression for pension contribution to restrict the sample to use

qui reghdfe cont_pens domwk_all treat_dwall `controls' if ${ctrl_group} == 1 & unemployed == 0, absorb(`base_controls' `occup') vce(cluster msa)
gen sample_reg = 1 if e(sample)

********************************************************************************
********************************************************************************

** Figure 1: Number of houses where a domestic worker is employed

cap graph drop before_reform after_reform
histogram n_employers if treat == 0 & sample_reg == 1, discrete frac start(1) width(1) lw(none) fcolor(teal) graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) plotregion(margin(b=0)) xscale(range(1 10)) xlabel(1(1)10)nodraw name(before_reform) subtitle("Before the reform")
histogram n_employers if treat == 1 & sample_reg == 1, discrete frac start(1) width(1) lw(none) fcolor(teal) graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) plotregion(margin(b=0)) xscale(range(1 10)) xlabel(1(1)10)nodraw name(after_reform) subtitle("After the reform")
graph combine before_reform after_reform, graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-1-original.tif", replace width(1200) height(900)

cap graph drop before_reform after_reform
histogram n_employers if treat == 0 & sample_reg == 1, discrete frac start(1) width(1) lw(none) fcolor(black) graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) plotregion(margin(b=0)) xscale(range(1 10)) xlabel(1(1)10)nodraw name(before_reform) subtitle("Before the reform")
histogram n_employers if treat == 1 & sample_reg == 1, discrete frac start(1) width(1) lw(none) fcolor(black) graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) plotregion(margin(b=0)) xscale(range(1 10)) xlabel(1(1)10)nodraw name(after_reform) subtitle("After the reform")
graph combine before_reform after_reform, graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-1-originalbw.tif", replace width(1200) height(900)


********************************************************************************
********************************************************************************

** Figure 2: Hours of work per week of domestic workers before and after the reform

twoway (histogram hours_mjob if domwk == 1 & treat == 0 & sample_reg == 1, start(0) w(5) lcolor(black) lw(vthin) fcolor(none)) ///
(histogram hours_mjob if domwk == 1 & treat == 1 & sample_reg == 1, start(0) w(5) lcolor(none) lw(vthin) fcolor(teal%30) xtitle("Hours of work per week")), ///
graphregion(fcolor(white) lcolor(white)) xscale(range(0 85)) xlabel(0(10)85) ylabel(,nogrid angle(horizontal)) legend(order(1 "Before the reform" 2 "After the reform")) plotregion(margin(b=0))
graph export "$figures/Feld-figure-2-original.tif", replace width(1200) height(900)

twoway (histogram hours_mjob if domwk == 1 & treat == 0 & sample_reg == 1, start(0) w(5) lcolor(black) lw(vthin) fcolor(none)) ///
(histogram hours_mjob if domwk == 1 & treat == 1 & sample_reg == 1, start(0) w(5) lcolor(none) lw(vthin) fcolor(black%50) xtitle("Hours of work per week")), ///
graphregion(fcolor(white) lcolor(white)) xscale(range(0 85)) xlabel(0(10)85) ylabel(,nogrid angle(horizontal)) legend(order(1 "Before the reform" 2 "After the reform")) plotregion(margin(b=0))
graph export "$figures/Feld-figure-2-originalbw.tif", replace width(1200) height(900)

********************************************************************************
********************************************************************************

** Figure 3: Index of searches for "domestic worker" over time

preserve

clear
import delimited "$data/Google trends.csv", clear delimiter(",")

gen month2 = monthly(month,"YM")
format month2 %tm

twoway line serviciodomesticoargentina month2, ytitle("Search index") ylabel(,nogrid angle(horizontal)) xtitle("Month") graphregion(fcolor(white) lcolor(white)) lcolor(black)
graph export "$figures/Feld-figure-3-originalbw.tif", replace width(1200) height(900)

restore

********************************************************************************
********************************************************************************

** Figure 4: Share of registered workers

* Run regressions to get the DiD coefficients to include in the graphs

local app replace

foreach var of varlist cont_pens lhours_mjob linc_mjob_base08 lwagehr_mjob_base08 linc_alljob_base08 linc_total_base08 lhours_alljob lwagehr_alljob_base08 {

	qui reghdfe `var' domwk_all `treatFE' `controls' if sample_reg == 1, absorb(`base_controls' `occup') vce(cluster msa)
	regsave y2010_dwall y2011_dwall y2013_dwall y2014_dwall y2015_dwall using "$data/did_coefs", ci `app' addlabel(outcome, "`var'")
	
	local app append
}

preserve


use "$data/did_coefs", clear

keep var coef ci_lower ci_upper outcome

rename var year

foreach yr in 2010 2011 2013 2014 2015 {
    
	replace year = "`yr'" if year == "y`yr'_dwall"
	
}

destring year, replace
replace outcome = "linc_total" if outcome == "linc_total_base08"
replace outcome = "linc_allj" if outcome == "linc_alljob_base08"
replace outcome = "lwagehr_mjob" if outcome == "lwagehr_mjob_base08"
replace outcome = "linc_mjob" if outcome == "linc_mjob_base08"
replace outcome = "lwagehr_allj" if outcome == "lwagehr_alljob_base08"


reshape wide coef ci_lower ci_upper, i(year) j(outcome) string


tempfile did_coefficients
save `did_coefficients'

restore

preserve

keep if sample_reg == 1

collapse (mean) cont_pens linc_mjob_base08 lwagehr_mjob_base08 lhours_mjob lhours_alljob linc_alljob_base08 lwagehr_alljob_base08 linc_total_base08, by(year domwk)

format cont_pens %9.2f

merge m:1 year using `did_coefficients'

foreach var of varlist coefcont_pens coeflhours_alljob coeflhours_mjob coeflinc_allj coeflinc_mjob coeflinc_total coeflwagehr_allj coeflwagehr_mjob {
    
	replace `var' = 0 if `var' == .
}

twoway (scatter cont_pens year if domwk == 0, m(s) mc(purple) c(line) lpattern(dash) lcolor(purple)) (scatter cont_pens year if domwk == 1, m(o) mc(maroon) c(line) lcolor(maroon)) ///
(scatter coefcont_pens year if domwk == 0, yaxis(2) m(X) mc(blue)) (rcap ci_lowercont_pens ci_uppercont_pens year if domwk == 0, yaxis(2) lcolor(blue)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI" )) xtitle("Year") xline(2012, lcolor(red)) xlabel(2010(1)2015) ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Share formal") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-4-original.tif", replace width(930) height(600)

twoway (scatter cont_pens year if domwk == 0, m(s) mc(black) c(line) lpattern(dash) lcolor(black)) (scatter cont_pens year if domwk == 1, m(o) mc(black) c(line) lcolor(black)) ///
(scatter coefcont_pens year if domwk == 0, yaxis(2) m(X) mc(black)) (rcap ci_lowercont_pens ci_uppercont_pens year if domwk == 0, yaxis(2) lcolor(black)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI" ) span) xtitle("Year") xline(2012, lcolor(blac)) xlabel(2010(1)2015) ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Share formal") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-4-originalbw.tif", replace width(930) height(600)


********************************************************************************
********************************************************************************

** Figure 5: Means of labor market outcomes per year and occupation

* Panel A: Hours of work per week on main job

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(purple) c(line) lpattern(dash) lcolor(purple)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(maroon) c(line) lcolor(maroon)) ///
(scatter coeflhours_mjob year if domwk == 0, yaxis(2) m(X) mc(blue)) (rcap ci_lowerlhours_mjob ci_upperlhours_mjob year if domwk == 0, yaxis(2) lcolor(blue)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(red)) xlabel(2010(1)2015) title("Panel A: Hours of work per week in main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log hours") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5a-original.tif", replace width(930) height(600)

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(black) c(line) lpattern(dash) lcolor(black)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(black) c(line) lcolor(black)) ///
(scatter coeflhours_mjob year if domwk == 0, yaxis(2) m(X) mc(black)) (rcap ci_lowerlhours_mjob ci_upperlhours_mjob year if domwk == 0, yaxis(2) lcolor(black)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(black)) xlabel(2010(1)2015) title("Panel A: Hours of work per week in main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log hours") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5a-originalbw.tif", replace width(930) height(600)

* Panel B: Wage per hour from main job

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(purple) c(line) lpattern(dash) lcolor(purple)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(maroon) c(line) lcolor(maroon)) ///
(scatter coeflwagehr_mjob year if domwk == 0, yaxis(2) m(X) mc(blue)) (rcap ci_lowerlwagehr_mjob ci_upperlwagehr_mjob year if domwk == 0, yaxis(2) lcolor(blue)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(red)) xlabel(2010(1)2015) title("Panel B: Wage per hour from main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log wage") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5b-original.tif", replace width(930) height(600)

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(black) c(line) lpattern(dash) lcolor(black)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(black) c(line) lcolor(black)) ///
(scatter coeflwagehr_mjob year if domwk == 0, yaxis(2) m(X) mc(black)) (rcap ci_lowerlwagehr_mjob ci_upperlwagehr_mjob year if domwk == 0, yaxis(2) lcolor(black)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(black)) xlabel(2010(1)2015) title("Panel B: Wage per hour from main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log wage") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5b-originalbw.tif", replace width(930) height(600)


* Panel C: Income per month from main job

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(purple) c(line) lpattern(dash) lcolor(purple)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(maroon) c(line) lcolor(maroon)) ///
(scatter coeflinc_mjob year if domwk == 0, yaxis(2) m(X) mc(blue)) (rcap ci_lowerlinc_mjob ci_upperlinc_mjob year if domwk == 0, yaxis(2) lcolor(blue)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(red)) xlabel(2010(1)2015) title("Panel C: Income per month from main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log income") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5c-original.tif", replace width(930) height(600)

twoway (scatter linc_mjob_base08 year if domwk == 0, m(s) mc(black) c(line) lpattern(dash) lcolor(black)) (scatter linc_mjob_base08 year if domwk == 1, m(o) mc(black) c(line) lcolor(black)) ///
(scatter coeflinc_mjob year if domwk == 0, yaxis(2) m(X) mc(black)) (rcap ci_lowerlinc_mjob ci_upperlinc_mjob year if domwk == 0, yaxis(2) lcolor(black)), ///
legend(order (1 "Low-wage female workers" 2 "Female domestic workers" 3 "DiD coefficient" 4 "95% CI") span) xtitle("Year") xline(2012, lcolor(black)) xlabel(2010(1)2015) title("Panel C: Income per month from main job") ///
ytitle("DiD coefficient", axis(2)) ylabel(,angle(horizontal) axis(1)) ylabel(,angle(horizontal) axis(2)) ytitle("Log income") graphregion(fcolor(white) lcolor(white)) 
graph export "$figures/Feld-figure-5c-originalbw.tif", replace width(930) height(600)


restore
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************

** Figure A1.1: Impact of domestic worker reform on wage distribution

preserve

keep if sample == 1


* Generate wage bins. The first bin goes from 0 to 1.25 as in Cengiz et al. (2019), then bins are of ARS 0.25

gen bin = 1 if wagehr_mjob_base08 > 0 & wagehr_mjob_base08 < 1.25
gen binwage = 0

local i = 2

forvalues w = 1.25(0.25)30 {
    
	local ub = `w' + 0.25
	
	replace bin = `i' if wagehr_mjob_base08 >= `w' & wagehr_mjob_base08 < `ub'
	replace binwage = `w' if wagehr_mjob_base08 >= `w' & wagehr_mjob_base08 < `ub'	
	
	local i = `i' + 1
}

replace bin = 117 if wagehr_mjob_base08 > 30 & !missing(wagehr_mjob_base08)


/* Include minimum wage data for domestic workers and non-domestic workers. This data was obtained from www.infoleg.gob.ar by searching foreach
the decrees that set the minimum wages over time and deflated using Pricestat's CPI */

gen minwage = .
replace minwage = 7.85 if time == tq(2010q1) & domwk == 1
replace minwage = 7.30 if time == tq(2010q2) & domwk == 1
replace minwage = 6.83 if time == tq(2010q3) & domwk == 1
replace minwage = 7.52 if time == tq(2010q4) & domwk == 1
replace minwage = 7.66 if time == tq(2011q1) & domwk == 1
replace minwage = 7.19 if time == tq(2011q2) & domwk == 1
replace minwage = 6.76 if time == tq(2011q3) & domwk == 1
replace minwage = 7.55 if time == tq(2011q4) & domwk == 1
replace minwage = 7.68 if time == tq(2012q1) & domwk == 1
replace minwage = 7.14 if time == tq(2012q2) & domwk == 1
replace minwage = 6.68 if time == tq(2012q3) & domwk == 1
replace minwage = 7.47 if time == tq(2012q4) & domwk == 1
replace minwage = 7.76 if time == tq(2013q1) & domwk == 1
replace minwage = 7.50 if time == tq(2013q2) & domwk == 1
replace minwage = 7.60 if time == tq(2013q3) & domwk == 1
replace minwage = 8.35 if time == tq(2013q4) & domwk == 1
replace minwage = 7.31 if time == tq(2014q1) & domwk == 1
replace minwage = 6.77 if time == tq(2014q2) & domwk == 1
replace minwage = 6.78 if time == tq(2014q3) & domwk == 1
replace minwage = 7.16 if time == tq(2014q4) & domwk == 1
replace minwage = 7.46 if time == tq(2015q1) & domwk == 1
replace minwage = 7.05 if time == tq(2015q2) & domwk == 1

replace minwage = 5.73 if time == tq(2010q1) & domwk == 0
replace minwage = 5.33 if time == tq(2010q2) & domwk == 0
replace minwage = 5.52 if time == tq(2010q3) & domwk == 0
replace minwage = 5.53 if time == tq(2010q4) & domwk == 0
replace minwage = 5.58 if time == tq(2011q1) & domwk == 0
replace minwage = 5.24 if time == tq(2011q2) & domwk == 0
replace minwage = 5.33 if time == tq(2011q3) & domwk == 0
replace minwage = 5.90 if time == tq(2011q4) & domwk == 0
replace minwage = 5.59 if time == tq(2012q1) & domwk == 0
replace minwage = 5.20 if time == tq(2012q2) & domwk == 0
replace minwage = 5.12 if time == tq(2012q3) & domwk == 0
replace minwage = 5.42 if time == tq(2012q4) & domwk == 0
replace minwage = 5.52 if time == tq(2013q1) & domwk == 0
replace minwage = 5.46 if time == tq(2013q2) & domwk == 0
replace minwage = 5.59 if time == tq(2013q3) & domwk == 0
replace minwage = 5.51 if time == tq(2013q4) & domwk == 0
replace minwage = 5.26 if time == tq(2014q1) & domwk == 0
replace minwage = 4.88 if time == tq(2014q2) & domwk == 0
replace minwage = 4.91 if time == tq(2014q3) & domwk == 0
replace minwage = 5.25 if time == tq(2014q4) & domwk == 0
replace minwage = 5.33 if time == tq(2015q1) & domwk == 0
replace minwage = 5.04 if time == tq(2015q2) & domwk == 0

* Generate wage differences

gen wagedif = binwage - minwage


* Collapse the data

collapse (count) pid (firstnm) binwage (mean) minwage wagedif, by(year domwk bin)

bysort year domwk: egen nworkers = total(pid)

gen sharebin = pid / nworkers


gen grm6 = wagedif >= -6 & wagedif < -5
gen grm5 = wagedif >= -5 & wagedif < -4
gen grm4 = wagedif >= -4 & wagedif < -3
gen grm3 = wagedif >= -3 & wagedif < -2
gen grm2 = wagedif >= -2 & wagedif < -1
gen grm1 = wagedif >= -1 & wagedif < 0
gen gr0 = wagedif >= 0 & wagedif < 1
gen gr1 = wagedif >= 1 & wagedif < 2
gen gr2 = wagedif >= 2 & wagedif < 3
gen gr3 = wagedif >= 3 & wagedif < 4
gen gr4 = wagedif >= 4 & wagedif < 5
gen gr5 = wagedif >= 5 & wagedif < 6
gen gr6 = wagedif >= 6 & wagedif < 7
gen gr7 = wagedif >= 7 & wagedif < 8
gen gr8 = wagedif >= 8 & wagedif < 9

forvalues i = 1/6 {
    
	local j = `i' - 1
	
    gen grm`i'_after_domwk = 0
	replace grm`i'_after_domwk = 1 if grm`i' == 1 & year >= 2013 & domwk == 1
	label var grm`i'_after_domwk "-$`i'"
	
}

forvalues i = 0/8 {
    
	local j = `i' + 1
    
    gen gr`i'_after_domwk = 0
	replace gr`i'_after_domwk = 1 if gr`i' == 1 & year >= 2013 & domwk == 1
	label var gr`i'_after_domwk "$`i'"
		
}


forvalues i = 2010/2015 {
    
	gen year`i' = year == `i'
	
}

tab bin, gen(bin)

forvalues i = 1/117 {
    
	gen bin`i'_2010 = bin`i'*year2010
	gen bin`i'_2011 = bin`i'*year2011
	gen bin`i'_2012 = bin`i'*year2012
	gen bin`i'_2013 = bin`i'*year2013
	gen bin`i'_2014 = bin`i'*year2014
	gen bin`i'_2015 = bin`i'*year2015
	gen bin`i'_domwk = bin`i'*domwk

}

reghdfe sharebin grm6_after_domwk grm5_after_domwk grm4_after_domwk grm3_after_domwk grm2_after_domwk grm1_after_domwk gr0_after_domwk-gr8_after_domwk, absorb(domwk#bin bin#year domwk#year) vce(unadjusted)

coefplot, keep(*_after_domwk) yline(0) vert title("Share of workers") xtitle("Wage bins in ARS relative to MW") graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) ytitle("Difference between the actual and" "counterfactual employment share") name(bin_num)

coefplot, keep(*_after_domwk) yline(0) vert title("Share of workers") xtitle("Wage bins in ARS relative to MW") graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) ytitle("Difference between the actual and" "counterfactual employment share") scheme(s2mono) name(bin_num_bw)

reghdfe pid grm6_after_domwk grm5_after_domwk grm4_after_domwk grm3_after_domwk grm2_after_domwk grm1_after_domwk gr0_after_domwk-gr8_after_domwk, absorb(domwk#bin bin#year domwk#year) vce(unadjusted)

coefplot, keep(*_after_domwk) yline(0) vert title("Number of workers") xtitle("Wage bins in ARS relative to MW") graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) ytitle("Difference between the actual and" "counterfactual employment count") name(bin_share)

coefplot, keep(*_after_domwk) yline(0) vert title("Number of workers") xtitle("Wage bins in ARS relative to MW") graphregion(fcolor(white) lcolor(white)) ///
ylabel(,nogrid angle(horizontal)) ytitle("Difference between the actual and" "counterfactual employment count") scheme(s2mono) name(bin_share_bw)

graph combine bin_num bin_share, col(1) graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-a1_1-original.tif", replace width(1200) height(900)

graph combine bin_num_bw bin_share_bw, col(1) graphregion(fcolor(white) lcolor(white)) scheme(s2mono)
graph export "$figures/Feld-figure-a1_1-originalbw.tif", replace width(1200) height(900)

graph drop _all

restore

********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************

** Figure OA5.1: Share of workers by occupation

** Number of domestic workers and non-domestic workers over time

gen hospitwk = (round(occupation/100) == 533 & domwk == 0)
gen touristwk = (round(occupation/100) == 543 & domwk == 0)
gen cleanwk = (round(occupation/100) == 563 & domwk == 0)
gen carewk = (round(occupation/100) == 573 & domwk == 0)
gen othwk = (round(occupation/100) == 583 & domwk == 0)


* Collapse the data at the quarter level

collapse (mean) share_domwk = domwk share_hospit = hospitwk share_tourist = touristwk share_clean = cleanwk share_care = carewk share_othwk = othwk (sum) number_domwk = domwk number_hospit = hospitwk number_tourist = touristwk number_clean = cleanwk number_care = carewk number_othwk = othwk, by(time)

format time %tqCCYY

** Figure OA5.1: Share of workers by occupation

twoway line share_domwk share_hospit share_tourist share_clean share_care share_othwk time, lpattern(solid shortdash longdash dash_dot vshortdash dash_3dot) ///
legend(order(1 "Domestic workers" 2 "Hospitality workers" 3 "Tourism workers" 4 "Cleaning workers" 5 "Caregivers" 6 "Other service workers") ///
row(2) span symxsize(8)) xtitle(Year) ytitle(Share of workforce) xline(212, lcolor(red)) xlabel(200(4)220) graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-oa5_1-original.tif", replace width(930) height(700)

twoway line share_domwk share_hospit share_tourist share_clean share_care share_othwk time, lpattern(solid shortdash longdash dash_dot vshortdash dash_3dot) ///
lcolor(black black black black black black) legend(order(1 "Domestic workers" 2 "Hospitality workers" 3 "Tourism workers" 4 "Cleaning workers" 5 "Caregivers" 6 "Other service workers") ///
row(2) span symxsize(8)) xtitle(Year) ytitle(Share of workforce) xline(212, lcolor(black)) xlabel(200(4)220) graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-oa5_1-originalbw.tif", replace width(930) height(700)


** Figure OA5.2: Number of workers by occupation

twoway line number_domwk number_hospit number_tourist number_clean number_care number_othwk time, lpattern(solid shortdash longdash dash_dot vshortdash dash_3dot) ///
legend(order(1 "Domestic workers" 2 "Hospitality workers" 3 "Tourism workers" 4 "Cleaning workers" 5 "Caregivers" 6 "Other service workers") ///
row(2) span symxsize(8)) xtitle(Year) ytitle(Number of workers) xline(212, lcolor(red)) xlabel(200(4)220) graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-oa5_2-original.tif", replace width(930) height(700)

twoway line number_domwk number_hospit number_tourist number_clean number_care number_othwk time, lpattern(solid shortdash longdash dash_dot vshortdash dash_3dot) ///
lcolor(black black black black black black) legend(order(1 "Domestic workers" 2 "Hospitality workers" 3 "Tourism workers" 4 "Cleaning workers" 5 "Caregivers" 6 "Other service workers") ///
row(2) span symxsize(8)) xtitle(Year) ytitle(Number of workers) xline(212, lcolor(black)) xlabel(200(4)220) graphregion(fcolor(white) lcolor(white))
graph export "$figures/Feld-figure-oa5_2-originalbw.tif", replace width(930) height(700)

exit